<template>
  <div class="addExpense">
    <el-form ref="form" :model="form" :rules="roleCodeRule" label-width="120px">
      <el-row>
        <mainTilte title="基本信息" />
      </el-row>
      <el-row>
        <el-col :span="6">
          <el-form-item label="商品分类">
            <product-category v-model="form.category_id" :disabled="true" />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="系统sku">
            <el-input v-model.trim="form.code" disabled />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="中文名称">
            <el-input v-model.trim="form.name_ch" disabled />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="英文名称" prop="name_en">
            <el-input v-model="form.name_en" disabled />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="运营类型">
            <el-input v-model.trim="form.operate_type" disabled />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="UPC条码">
            <el-input v-model.trim="form.bar_code_upc" disabled />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="产品条码">
            <el-input v-model.trim="form.bar_code" disabled />
          </el-form-item>
        </el-col>
        <el-col v-if="form.type == 1" :span="6">
          <el-form-item label="产品条码2">
            <el-input v-model.trim="form.bar_code2" disabled />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="所属供应商">
            <el-input :value="supplier_name" disabled />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="采购员">
            <el-input v-model.trim="form.purchase_name" disabled />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="所属客户">
            <el-input v-model.trim="form.company_name" disabled />
          </el-form-item>
        </el-col>
        <!-- <el-col :span="6">
          <el-form-item label="产品条码1" prop="domestic_trans.traile_fee">
            <el-input v-model.trim="form.domestic_trans.traile_fee"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="产品条码2" prop="domestic_trans.traile_fee">
            <el-input v-model.trim="form.domestic_trans.traile_fee"></el-input>
          </el-form-item>
        </el-col> -->
        <el-col v-if="form.type == 0 && form.purchase_price_rmb" :span="6">
          <el-form-item label="采购价(RMB)">
            <el-input v-model.trim="form.purchase_price_rmb" disabled />
          </el-form-item>
        </el-col>
        <el-col v-if="form.type == 0 && form.purchase_price_usd" :span="6">
          <el-form-item label="采购价(USD)">
            <el-input v-model.trim="form.purchase_price_usd" disabled />
          </el-form-item>
        </el-col>
        <el-col v-if="form.type == 1" :span="6">
          <el-form-item label="申报单价(USD)">
            <el-input v-model.trim="form.purchase_price_usd" disabled />
          </el-form-item>
        </el-col>
        <el-col v-if="form.type == 1" :span="6">
          <el-form-item label="保险价值(USD)">
            <el-input v-model.trim="form.insured_price_usd" disabled />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="是否保价">
            <el-input v-model.trim="form.insured_price" disabled />
          </el-form-item>
        </el-col>
        <el-col v-if="form.insured_price == '保价'" :span="6">
          <el-form-item label="保值">
            <el-input v-model.trim="form.hedge_price" disabled />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="包装方式">
            <el-input v-model.trim="packing_method" disabled />
          </el-form-item>
        </el-col>
        <el-col v-if="packing_method == '普通商品'" :span="6">
          <el-form-item label="可合并发货数量">
            <el-input v-model.trim="form.merge_num" disabled />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="商品主图">
            <el-image v-if="form.image_url" :src="form.image_url" class="img" fit="cover" :preview-src-list="[ form.image_url ]" />
            <i v-else class="el-icon-plus avatar-uploader-icon" />
          </el-form-item>
        </el-col>
      </el-row>
      <div v-if="form.otherData">
        <el-row>
          <mainTilte title="产品信息" />
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="尺寸">
              <el-input v-model="form.otherData.size" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="重量">
              <el-input v-model="form.otherData.weight" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="颜色">
              <el-input v-model="form.otherData.color" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="材质">
              <el-input v-model="form.otherData.material" type="textarea" autosize disabled />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="配件">
              <el-input v-model.trim="form.otherData.parts" type="textarea" autosize disabled />
            </el-form-item>
          </el-col>
          <el-col v-if="form.type == 1" :span="6">
            <el-form-item label="用途">
              <el-input v-model.trim="form.purpose" type="textarea" autosize disabled />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="其他备注">
              <el-input v-model="form.otherData.other_remark" type="textarea" autosize disabled />
            </el-form-item>
          </el-col>
        </el-row>
      </div>

      <el-row>
        <mainTilte title="关税信息" />
      </el-row>
      <el-row>
        <el-col :span="6">
          <el-form-item label="国内(HS)">
            <el-input v-model.trim="form.ZH_HS" disabled />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="国外(HS)">
            <el-input v-model.trim="form.EN_HS" disabled />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="国内退税率">
            <el-input v-model.trim="form.tax_rebate_rate" disabled />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="国外关税税率">
            <el-input v-model.trim="form.tax_tariff_rate" disabled />
          </el-form-item>
        </el-col>
      </el-row>
      <div
        v-if="
          packing_method == '多箱包装' &&
            form.groupData &&
            form.groupData.length > 0
        "
      >
        <el-row>
          <mainTilte title="商品分组" />
        </el-row>
        <el-row v-if="form.groupData && form.groupData.length > 0">
          <el-table :data="form.groupData" stripe fit border>
            <el-table-column prop="number" label="名称" width="180" align="center">
              <template slot-scope="scope">
                <p>{{ scope.row.name }}</p>
              </template>
            </el-table-column>
            <!-- <el-table-column
              prop="number"
              label="数量"
              width="180"
              align="center"
            >
              <template slot-scope="scope">
                <p>{{ scope.row.number }}</p>
              </template>
            </el-table-column> -->
            <el-table-column prop="number" label="尺寸公制(长)" width="180" align="center">
              <template slot-scope="scope">
                <p>{{ scope.row.length }}</p>
              </template>
            </el-table-column>
            <el-table-column prop="number" label="尺寸公制(宽)" width="180" align="center">
              <template slot-scope="scope">
                <p>{{ scope.row.width }}</p>
              </template>
            </el-table-column>
            <el-table-column prop="number" label="尺寸公制(高)" width="180" align="center">
              <template slot-scope="scope">
                <p>{{ scope.row.height }}</p>
              </template>
            </el-table-column>
            <el-table-column prop="volume" label="体积(公制)" width="180" align="center">
              <template slot-scope="scope">
                {{ scope.row.volume }}
              </template>
            </el-table-column>
            <el-table-column prop="length_AS" label="尺寸美制(长)" width="180" align="center">
              <template slot-scope="scope">
                <p>{{ scope.row.length_AS }}</p>
              </template>
            </el-table-column>
            <el-table-column prop="width_AS" label="尺寸美制(宽)" width="180" align="center">
              <template slot-scope="scope">
                <p>{{ scope.row.width_AS }}</p>
              </template>
            </el-table-column>
            <el-table-column prop="height_AS" label="尺寸美制(高)" width="180" align="center">
              <template slot-scope="scope">
                <p>{{ scope.row.height_AS }}</p>
              </template>
            </el-table-column>
            <!-- <el-table-column
              prop="volume_AS"
              label="体积(美制)"
              width="180"
              align="center"
            >
              <template slot-scope="scope">
                {{ scope.row.volume_AS }}
              </template>
            </el-table-column> -->
            <el-table-column prop="volume_weight_AS" label="体积重(美制)" width="180" align="center">
              <template slot-scope="scope">
                {{ scope.row.volume_weight_AS }}
              </template>
            </el-table-column>
            <el-table-column prop="weight_gross_AS" label="毛重(美制)" width="180" align="center">
              <template slot-scope="scope">
                <p>{{ scope.row.weight_gross_AS }}</p>
              </template>
            </el-table-column>
            <el-table-column prop="weight_AS" label="净重(美制)" width="180" align="center">
              <template slot-scope="scope">
                <p>{{ scope.row.weight_AS }}</p>
              </template>
            </el-table-column>
            <el-table-column prop="oversize" label="Oversize" width="180" align="center">
              <template slot-scope="scope">
                <p>{{ scope.row.oversize }}</p>
              </template>
            </el-table-column>
          </el-table>
        </el-row>
      </div>
      <div v-if="form.packData && form.packing_method===1">
        <el-row>
          <mainTilte title="包装信息" />
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="尺寸(公制)">
              <div class="sizeStyle">
                <div>
                  <el-input v-model="form.packData.length" placeholder="长" disabled>
                    <template slot="append">CM</template>
                  </el-input>
                </div>
                <div style="margin-left: 8px">
                  <el-input v-model="form.packData.width" placeholder="宽" disabled>
                    <template slot="append">CM</template>
                  </el-input>
                </div>
                <div style="margin-left: 8px">
                  <el-input v-model="form.packData.height" placeholder="高" disabled>
                    <template slot="append">CM</template>
                  </el-input>
                </div>
              </div>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="体积(公制)">
              <el-input v-model.trim="form.packData.volume" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="尺寸(美制)">
              <div class="sizeStyle">
                <div>
                  <el-input v-model="form.packData.length_AS" placeholder="长" disabled>
                    <template slot="append">英寸</template>
                  </el-input>
                </div>
                <div style="margin-left: 8px">
                  <el-input v-model="form.packData.width_AS" placeholder="宽" disabled>
                    <template slot="append">英寸</template>
                  </el-input>
                </div>
                <div style="margin-left: 8px">
                  <el-input v-model="form.packData.height_AS" placeholder="高" disabled>
                    <template slot="append">英寸</template>
                  </el-input>
                </div>
              </div>
            </el-form-item>
          </el-col>
          <!-- <el-col :span="8">
            <el-form-item label="体积(美制)">
              <el-input v-model.trim="form.packData.volume_AS" disabled />
            </el-form-item>
          </el-col> -->
          <el-col :span="8">
            <el-form-item label="体积重(美制)">
              <el-input v-model.trim="form.packData.volume_weight_AS" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="Oversize参数">
              <el-input v-model.trim="form.packData.oversize" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="毛重(公制)">
              <el-input v-model="form.packData.weight_gross" placeholder="请输入内容" disabled>
                <template slot="append">kg</template>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="毛重(美制)">
              <el-input v-model="form.packData.weight_gross_AS" placeholder="请输入内容" disabled>
                <template slot="append">lbs</template>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="净重(公制)">
              <el-input v-model="form.packData.weight" placeholder="请输入内容" disabled>
                <template slot="append">kg</template>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="净重(美制)">
              <el-input v-model="form.packData.weight_AS" placeholder="请输入内容" disabled>
                <template slot="append">lbs</template>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="40HQ装箱量">
              <el-input v-model.trim="form.packData.hq_size" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="箱率">
              <el-input v-model.trim="form.packData.box_rate" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="运输包装尺寸">
              <div class="sizeStyle">
                <div>
                  <el-input v-model="form.packData.transport_length" placeholder="长" disabled>
                    <template slot="append">CM</template>
                  </el-input>
                </div>
                <div style="margin-left: 8px">
                  <el-input v-model="form.packData.transport_width" placeholder="宽" disabled>
                    <template slot="append">CM</template>
                  </el-input>
                </div>
                <div style="margin-left: 8px">
                  <el-input v-model="form.packData.transport_height" placeholder="高" disabled>
                    <template slot="append">CM</template>
                  </el-input>
                </div>
              </div>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="运输外箱体积">
              <el-input v-model.trim="form.packData.outside_transport_volume" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="计量单位">
              <el-select v-model="form.packData.unit" disabled>
                <el-option v-for="(item, index) in unitList" :key="index" :label="item.dict_data_name" :value="`${item.id}`" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col v-if="form.type == 1" :span="8">
            <el-form-item label="是否支持拆单">
              <el-input v-model.trim="splitBill" disabled />
            </el-form-item>
          </el-col>
          <el-col v-if="form.type == 1" :span="8">
            <el-form-item label="包装类型">
              <el-input v-model.trim="form.packData.packing_type" disabled />
            </el-form-item>
          </el-col>
          <el-col v-if="form.type == 1" :span="8">
            <el-form-item label="是否需要序列号">
              <el-input v-model.trim="form.packData.is_serial_number" disabled />
            </el-form-item>
          </el-col>
          <el-col v-if="form.type == 1" :span="8">
            <el-form-item label="是否带电">
              <el-input v-model.trim="form.packData.is_electric" disabled />
            </el-form-item>
          </el-col>
          <el-col v-if="form.type == 1" :span="8">
            <el-form-item label="打包设置">
              <el-input v-model.trim="form.packData.pack_set" disabled />
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <div style="margin-top:20px" />
      <el-row>
        <mainTilte title="附件信息" />
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item label="商品说明书">
            <uploadFile :file-list="fileListDescription" :disabled="true" accept-type="application/pdf,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" list-type="text" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="箱唛">
            <uploadFile :file-list="fileListmark" :disabled="true" accept-type="application/pdf,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" list-type="text" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="其他资料">
            <uploadFile :file-list="fileListother" :disabled="true" accept-type="application/pdf,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" list-type="text" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item label="整箱产品组成图片">
            <uploadFile :file-list="fileListpictures" :disabled="true" accept-type="image/jpeg,image/png" list-type="picture-card" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="产品包装细节图">
            <uploadFile :file-list="fileListdetail" :disabled="true" accept-type="image/jpeg,image/png" list-type="picture-card" />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>

<script>
import { fileTransform } from '@/filters/index'
export default {
  props: {
    form: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  data() {
    return {
      // form: {
      //   value: "",
      // },
      roleCodeRule: {}
    }
  },
  computed: {
    supplier_name() {
      const { supplier_names, supplier_name } = this.form
      return supplier_names || supplier_name
    },
    fileListDescription() {
      if (this.form.otherData && this.form.otherData.descriptio) {
        return fileTransform(this.form.otherData.description)
      } else {
        return ''
      }
    },
    fileListmark() {
      if (this.form.otherData && this.form.otherData.box_mark) {
        return fileTransform(this.form.otherData.box_mark)
      } else {
        return ''
      }
    //   return fileTransform(this.form.otherData.box_mark ?? '')
    },
    fileListother() {
      if (this.form.otherData && this.form.otherData.other) {
        return fileTransform(this.form.otherData.other)
      } else {
        return ''
      }
    //   return fileTransform(this.form.otherData.other)
    },
    fileListpictures() {
      if (this.form.otherData && this.form.otherData.pictures) {
        return fileTransform(this.form.otherData.pictures)
      } else {
        return ''
      }
    //   return fileTransform(this.form.otherData.pictures)
    },
    fileListdetail() {
      if (this.form.otherData && this.form.otherData.detail_pictures) {
        return fileTransform(this.form.otherData.detail_pictures)
      } else {
        return ''
      }
    //   return fileTransform(this.form.otherData.detail_pictures)
    },
    // 包装方式
    packing_method() {
      return this.form.packing_method === 1 ? '普通商品' : '多箱包装'
    },
    // 是否支持拆单
    splitBill() {
      return this.form.packing_method === 1 ? '否' : '是'
    }
  },
  methods: {
    columnsHandler() { }
  }
}
</script>

<style scoped>
.addExpense {
  padding: 15px;
  background: #fff;
}
.addExpense /deep/.el-select,
.el-autocomplete,
.el-cascader {
  width: 100%;
}
.sizeStyle {
  display: flex;
}
.sizeStyle /deep/ .el-input__inner {
  border-right: 0;
}
.sizeStyle /deep/ .el-input-group__append {
  padding-left: 4px;
  padding-right: 4px;
  font-size: 14px;
  color: #333333;
  background: #fff;
}
.avatar-uploader /deep/ .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader /deep/ .el-upload:hover {
  border-color: #409eff;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 120px;
  height: 120px;
  line-height: 120px;
  text-align: center;
}
.avatar {
  width: 120px;
  height: 120px;
  display: block;
}
</style>
